/**
 * 
 */
package lt.inkredibl.iit;

import java.io.File;

import javax.swing.filechooser.FileFilter;

public final class ImgFileChooser
	extends FileFilter
{
	@Override
	public boolean accept(File f)
	{
		if (f.isDirectory())
		{
			return true;
		}
		String fname = f.getName();
		int pos = fname.lastIndexOf('.');
		if (pos != -1)
		{
			String ext = fname.substring(pos+1);
			return ext.equalsIgnoreCase("png")
				|| ext.equalsIgnoreCase("jpg")
				|| ext.equalsIgnoreCase("jpeg")
				|| ext.equalsIgnoreCase("gif")
				|| ext.equalsIgnoreCase("bmp");
		}
		else
		{
			return false;
		}
	}

	@Override
	public String getDescription()
	{
		return "Image files";
	}

	public static FileFilter inst()
	{
		return new ImgFileChooser();
	}
}